/*
 * Copyright (c) 2025 Industrial Software Feature Database
 */
package com.comac.ins.bomt.repository.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.comac.ins.bomt.common.enums.BizStepEnum;
import com.comac.ins.bomt.common.enums.BomInfoStatusEnum;
import com.comac.ins.bomt.common.enums.StandardBomSrcTypeEnum;
import com.comac.ins.bomt.domain.*;
import com.comac.ins.bomt.domain.vo.*;
import com.comac.ins.bomt.mapper.*;
import com.comac.ins.bomt.repository.BomRepositoryV2;
import com.comac.ins.bomt.service.BomQueryServiceV2;
import com.comac.ins.common.biz.event.BizEventService;
import com.comac.ins.common.core.domain.model.LoginUser;
import com.comac.ins.common.biz.utils.BizAssertUtil;
import com.comac.ins.common.core.utils.MapstructUtils;
import com.comac.ins.common.json.utils.JsonUtils;
import com.comac.ins.common.mybatis.core.mapper.BaseMapperPlus;
import com.comac.ins.common.mybatis.helper.BaseEntityHelper;
import com.comac.ins.common.redis.utils.RedisUtils;
import com.comac.ins.isfd.constant.RedisConstants;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.text.MessageFormat;
import java.util.*;
import java.util.concurrent.atomic.AtomicLong;
import java.util.stream.Collectors;

/**
 * @author zhanghongyi
 * @date 2024/8/13 11:11
 * @description BomRepositoryV2Impl
 */
@RequiredArgsConstructor
@Service
@Slf4j
public class BomRepositoryV2Impl implements BomRepositoryV2 {

    private final BomQueryServiceV2 bomQueryServiceV2;

    private final BomtOriginalBomV2DetailMapper originalBomV2DetailMapper;
    private final BomtOriginalBomV2InfoMapper originalBomV2InfoMapper;


    private final BomtStandardBomV2DetailMapper standardBomV2DetailMapper;
    private final BomtStandardBomV2InfoMapper standardBomV2InfoMapper;

    private final BomtStrengthBomV2DetailMapper strengthBomV2DetailMapper;
    private final BomtStrengthBomV2InfoMapper strengthBomV2InfoMapper;



    @Override
    @Transactional(rollbackFor = Exception.class)
    public void initOriginalBom(LoginUser loginUser, OriginalBomV2InfoVo originalBomV2InfoVo) {
        BizAssertUtil.notNull(originalBomV2InfoVo, "originalBomInfoVo is null");
        BizAssertUtil.notEmpty(originalBomV2InfoVo.getDetails(), "originalBomInfo.detail is empty");
        BizEventService.updateCurrentMsg("入库原始清单...总数:{}", originalBomV2InfoVo.getDetails().size());
        //入库
        AtomicLong index = new AtomicLong();
        List<DetailOriginalV2Bom> records = originalBomV2InfoVo.getDetails().stream().map(
            vo -> {
                DetailOriginalV2Bom detailOriginalV2Bom = MapstructUtils.convert(vo, DetailOriginalV2Bom.class);
                BizAssertUtil.notNull(detailOriginalV2Bom, "convert detailOriginalBom fail");
                BaseEntityHelper.fillCreateByAndUpdateBy(detailOriginalV2Bom, loginUser);
                detailOriginalV2Bom.setId(null);
                detailOriginalV2Bom.setAircraftModel(originalBomV2InfoVo.getAircraftModel());
                detailOriginalV2Bom.setTrack(originalBomV2InfoVo.getTrack());
                detailOriginalV2Bom.setSubTrack(originalBomV2InfoVo.getSubTrack());
                detailOriginalV2Bom.setOrd(index.incrementAndGet());
                detailOriginalV2Bom.setGroupType(originalBomV2InfoVo.getGroupType());
                return detailOriginalV2Bom;
            }
        ).toList();
        BizAssertUtil.isTrue(insertBatch(originalBomV2DetailMapper, records),"insert original bom detail fail");
        OriginalBomV2Info originalBomV2Info = MapstructUtils.convert(originalBomV2InfoVo, OriginalBomV2Info.class);
        BizAssertUtil.notNull(originalBomV2Info, "originalBomInfo is null");
        BaseEntityHelper.fillCreateByAndUpdateBy(originalBomV2Info, loginUser);
        originalBomV2Info.setDetailCnt((long)records.size());
        originalBomV2Info.setStatus(BomInfoStatusEnum.DONE.getCode());
        originalBomV2Info.setBizStep(BizStepEnum.INIT.getType());
        BizAssertUtil.isTrue(originalBomV2InfoMapper.insert(originalBomV2Info) == 1, "insert originalBomInfo fail");
        BizEventService.updateCurrentMsg("原始清单入库完毕");
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public Map<String,Long> initStandardBom(LoginUser loginUser,OriginalBomV2InfoVo originalBomV2InfoVo, Map<String, List<DetailStandardV2BomVo>> detailStandardBomVosMap,String desc) {
        Map<String,Long> result = new HashMap<>();
        BizAssertUtil.notEmpty(detailStandardBomVosMap, "detailStandardBomVosMap is empty");
        if(null != originalBomV2InfoVo) {
            BizEventService.updateCurrentMsg("标准清单：清理历史记录");
            //删除存量
            QueryWrapper<DetailStandardV2Bom> detailWrapper = new QueryWrapper<>();
            detailWrapper.eq("track", originalBomV2InfoVo.getTrack());
            detailWrapper.eq("sub_track", originalBomV2InfoVo.getSubTrack());
            detailWrapper.eq("aircraft_model", originalBomV2InfoVo.getAircraftModel());
            if (standardBomV2DetailMapper.selectCount(detailWrapper) > 0) {
                List<Long> ids = standardBomV2DetailMapper.selectList(detailWrapper).stream().map(DetailStandardV2Bom::getId).collect(Collectors.toList());
                standardBomV2DetailMapper.deleteBatchIds(ids);
            }
            QueryWrapper<StandardBomV2Info> wrapper = new QueryWrapper<>();
            wrapper.eq("track", originalBomV2InfoVo.getTrack());
            wrapper.eq("sub_track", originalBomV2InfoVo.getSubTrack());
            wrapper.eq("aircraft_model", originalBomV2InfoVo.getAircraftModel());
            if (standardBomV2InfoMapper.selectCount(wrapper) > 0) {
                List<Long> ids = standardBomV2InfoMapper.selectList(wrapper).stream().map(StandardBomV2Info::getId).collect(Collectors.toList());
                standardBomV2InfoMapper.deleteBatchIds(ids);
            }
        }
        //入库
        for (Map.Entry<String, List<DetailStandardV2BomVo>> entry : detailStandardBomVosMap.entrySet()){
            BizEventService.updateCurrentMsg("标准清单:入库{}",entry.getKey());
            List<DetailStandardV2BomVo> detailStandardBomVos = entry.getValue();
            BizAssertUtil.notEmpty(detailStandardBomVos, "detailStandardBomVos is empty");
            List<DetailStandardV2Bom> details = MapstructUtils.convert(detailStandardBomVos, DetailStandardV2Bom.class);
            BizAssertUtil.notNull(details, "detailStandardBomVos is null");
            StandardBomV2InfoVo standardBomV2InfoVo;
            if(null != originalBomV2InfoVo) {
                standardBomV2InfoVo = StandardBomV2InfoVo.createFromOriginalBom(originalBomV2InfoVo, entry.getValue().get(0).getMainSection(), entry.getValue().get(0).getSection());
            }else{
                standardBomV2InfoVo = StandardBomV2InfoVo.createFromDetails(entry.getValue(),desc);
            }
            StandardBomV2Info standardBomV2Info = MapstructUtils.convert(standardBomV2InfoVo, StandardBomV2Info.class);
            BizAssertUtil.notNull(standardBomV2Info, "standardBomV2Info is null");
            standardBomV2Info.setSummary(JsonUtils.toJsonString(StandardBomV2SummaryInfo.builder()
                .count((long)details.size())
                .distinctCodeCount(details.stream().map(DetailStandardV2Bom::getCode).distinct().count())
                .build()));
            standardBomV2InfoMapper.insert(standardBomV2Info);
            details.forEach(item->{
                BaseEntityHelper.fillCreateByAndUpdateBy(item, loginUser);
                item.setInfoId(standardBomV2Info.getId());
            });
            insertBatch(standardBomV2DetailMapper,details);
            result.put(entry.getKey(),standardBomV2Info.getId());
            BizEventService.updateCurrentMsg("标准清单:入库完毕{}",entry.getKey());
        }
        return result;
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void initStrengthBom(LoginUser loginUser, String groupCode, String groupName, StandardBomV2Info standardBomV2Info, List<DetailStrengthV2Bom> details, Map<String, Long> sectionStandardInfoIdMap) {
        String aircraftModel;
        String track;
        if (null != standardBomV2Info) {
            aircraftModel = standardBomV2Info.getAircraftModel();
            track = standardBomV2Info.getTrack();
        } else {
            aircraftModel = details.get(0).getAircraftModel();
            track = details.get(0).getTrack();
        }

        //删除存量
        QueryWrapper<DetailStrengthV2Bom> detailWrapper = new QueryWrapper<>();
        detailWrapper.eq("group_type", groupCode);
        detailWrapper.eq("track", track);
        detailWrapper.eq("aircraft_model", aircraftModel);
        if (strengthBomV2DetailMapper.selectCount(detailWrapper) > 0) {
            BizEventService.updateCurrentMsg("强度数模清单：清理历史记录");
            List<Long> ids = strengthBomV2DetailMapper.selectList(detailWrapper).stream().map(DetailStrengthV2Bom::getId).collect(Collectors.toList());
            strengthBomV2DetailMapper.deleteBatchIds(ids);
        }
        QueryWrapper<StrengthBomV2Info> infoWrapper = new QueryWrapper<>();
        infoWrapper.eq("group_type", groupCode);
        infoWrapper.eq("track", track);
        infoWrapper.eq("aircraft_model", aircraftModel);
        if (strengthBomV2InfoMapper.selectCount(infoWrapper) > 0) {
            List<StrengthBomV2Info> strengthBomList = strengthBomV2InfoMapper.selectList(infoWrapper).stream().toList();
            strengthBomV2InfoMapper.deleteBatchIds(strengthBomList.stream().map(StrengthBomV2Info::getId).toList());
            List<StandardBomV2Info> standardInfos = standardBomV2InfoMapper.selectBatchIds(strengthBomList.stream().map(StrengthBomV2Info::getStandardBomInfoId).filter(Objects::nonNull).toList());
            standardInfos.forEach(item -> {
                item.setStatus(BomInfoStatusEnum.DONE.getCode());
                item.setBizStep(BizStepEnum.INIT.getType());
                standardBomV2InfoMapper.updateById(item);
            });
        }
        //入库
        BizEventService.updateCurrentMsg("强度数模清单：入库{}", groupCode);
        StrengthBomV2Info strengthBomInfo = new StrengthBomV2Info();

        if (null != standardBomV2Info) {
            BeanUtils.copyProperties(standardBomV2Info, strengthBomInfo);
            strengthBomInfo.setStandardBomInfoId(standardBomV2Info.getId());
        } else {
            strengthBomInfo.setAircraftModel(details.get(0).getAircraftModel());
            strengthBomInfo.setTrack(details.get(0).getTrack());
            strengthBomInfo.setStandardBomInfoId(sectionStandardInfoIdMap.get(groupName));
            strengthBomInfo.setSubTrack(details.get(0).getSubTrack());
            strengthBomInfo.setSection(groupName);
            strengthBomInfo.setMainSection(groupName);
        }
        strengthBomInfo.setGroupType(groupCode);
        strengthBomInfo.setSubGroupType(null);
        strengthBomInfo.setId(null);
        strengthBomInfo.setStatus(BomInfoStatusEnum.DONE.getCode());
        strengthBomInfo.setBizStep(BizStepEnum.INIT.getType());
        strengthBomInfo.setErrorMsg(null);
        strengthBomInfo.setExtraInfo(null);
        strengthBomInfo.setSummary(JsonUtils.toJsonString(StrengthBomV2SummaryInfo.builder()
            .count((long) details.size())
            .distinctCodeCount(details.stream().map(DetailStrengthV2Bom::getCode).distinct().count())
            .build()));
        BaseEntityHelper.fillCreateByAndUpdateBy(strengthBomInfo, loginUser);
        BizAssertUtil.isTrue(strengthBomV2InfoMapper.insert(strengthBomInfo) > 0, "插入强度清单信息失败");
        BizAssertUtil.notEmpty(details, "strengthDetails is empty");
        details.forEach(item -> {
            item.setId(null);
            item.setGroupType(groupCode);
            item.setSubGroupType(null);
            item.setInfoId(strengthBomInfo.getId());
        });
        BizAssertUtil.isTrue(insertBatch(strengthBomV2DetailMapper,details), "插入强度清单明细失败");
        BizEventService.updateCurrentMsg("强度清单:入库完毕{}",groupCode);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void modifyStrengthBom(LoginUser loginUser, Long srcStrengthBomId, List<Long> deleteDetailIds,List<DetailStrengthV2BomVo> modifyDetails, String desc) {
        if(CollectionUtils.isNotEmpty(deleteDetailIds)){
            int delRet = strengthBomV2DetailMapper.deleteBatchIds(deleteDetailIds);
            BizAssertUtil.isTrue(delRet == deleteDetailIds.size(), "delete strength bom detail fail");
        }
        if(CollectionUtils.isNotEmpty(modifyDetails)){
            boolean updateRet = strengthBomV2DetailMapper.updateBatchById(MapstructUtils.convert(modifyDetails, DetailStrengthV2Bom.class));
            BizAssertUtil.isTrue(updateRet, "update strength bom detail fail");
        }
        updateStrengthBomSummary(srcStrengthBomId);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void modifyOriginalBom(LoginUser loginUser, DetailOriginalV2BomVo modifyDetail) {
        DetailOriginalV2Bom dbDetail = originalBomV2DetailMapper.selectById(modifyDetail.getId());
        BizAssertUtil.notNull(dbDetail, "can't find original bom detail record");
        DetailOriginalV2Bom detailOriginalV2Bom = MapstructUtils.convert(modifyDetail, DetailOriginalV2Bom.class);
        originalBomV2DetailMapper.updateById(detailOriginalV2Bom);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void copyStandardBom(LoginUser loginUser, Long srcStandardBomId, List<Long> deleteDetailIds,List<DetailStandardV2BomVo> modifyDetails, String desc) {
        StandardBomV2Info standardBomInfo = bomQueryServiceV2.queryStandardBomInfoById(loginUser, srcStandardBomId);
        BizAssertUtil.notNull(standardBomInfo, "can't find standard bom info record");
        List<DetailStandardV2BomVo> modifiedDetails = CollectionUtils.isEmpty(modifyDetails) ? new ArrayList<>() : modifyDetails;
        List<Long> deletedDetailIds = CollectionUtils.isEmpty(deleteDetailIds) ? new ArrayList<>() : deleteDetailIds;
        Set<Long> modifyDetailIds = modifiedDetails.stream().map(DetailStandardV2BomVo::getId).collect(Collectors.toSet());
        List<DetailStandardV2Bom> details = bomQueryServiceV2.queryStandardBomDetailByInfoId(loginUser, standardBomInfo.getAircraftModel(), srcStandardBomId);
        List<DetailStandardV2Bom> processedDetails = details.stream()
            .filter(item -> !deletedDetailIds.contains(item.getId()))
            .map(item -> {
                if (modifyDetailIds.contains(item.getId())) {
                    DetailStandardV2BomVo modifyDetail = modifiedDetails.stream().filter(detail -> detail.getId().equals(item.getId())).findFirst().get();
                    modifyDetail.checkParam();
                    DetailStandardV2Bom modifyItem = MapstructUtils.convert(modifyDetail, DetailStandardV2Bom.class);
                    return modifyItem;
                } else {
                    return item;
                }
            }).toList();
        StandardBomV2Info copiedStandardBomInfo = new StandardBomV2Info();
        BeanUtils.copyProperties(standardBomInfo, copiedStandardBomInfo);
        BaseEntityHelper.fillCreateByAndUpdateBy(copiedStandardBomInfo, loginUser);
        copiedStandardBomInfo.setExtraInfo(null);
        copiedStandardBomInfo.setErrorMsg(null);
        copiedStandardBomInfo.setSubTrack(MessageFormat.format("{0}_{1}", copiedStandardBomInfo.getAircraftModel(), DateFormatUtils.format(new Date(), "yyyy_MM_dd_HHmmssSSSSSS")));
        copiedStandardBomInfo.setSrcType(StandardBomSrcTypeEnum.MODIFY.getType());
        copiedStandardBomInfo.setSrcDesc(desc);
        copiedStandardBomInfo.setStatus(BomInfoStatusEnum.DONE.getCode());
        copiedStandardBomInfo.setBizStep(BizStepEnum.INIT.getType());
        copiedStandardBomInfo.setSummary(JsonUtils.toJsonString(StandardBomV2SummaryInfo.builder()
            .count((long)processedDetails.size())
            .distinctCodeCount(processedDetails.stream().map(DetailStandardV2Bom::getCode).distinct().count())
            .build()));
        copiedStandardBomInfo.setId(null);
        standardBomV2InfoMapper.insert(copiedStandardBomInfo);
        AtomicLong index = new AtomicLong();
        List<DetailStandardV2Bom> copyDetails = processedDetails.stream().map(item -> {
            BizAssertUtil.notNull(item, "convert detailStandardBomVo fail");
            item.setInfoId(copiedStandardBomInfo.getId());
            item.setOrd(index.incrementAndGet());
            item.setId(null);
            return item;
        }).collect(Collectors.toList());
        insertBatch(standardBomV2DetailMapper,copyDetails);
    }


    @Override
    @Transactional(rollbackFor = Exception.class)
    public void deleteOriginalBomDetails(LoginUser loginUser,List<Long> deleteIds) {
        BizAssertUtil.notEmpty(deleteIds, "deleteIds is empty");
        List<DetailOriginalV2Bom> details = originalBomV2DetailMapper.selectBatchIds(deleteIds);
        BizAssertUtil.isTrue(details.stream().map(item->item.getAircraftModel()+item.getTrack()+item.getSubTrack()).distinct().toList().size()==1,"deleteIds not same group");
        int delRet = originalBomV2DetailMapper.deleteBatchIds(deleteIds);
        BizAssertUtil.isTrue(delRet == deleteIds.size(), "delete original bom detail fail");
        updateOriginalBomSummary(loginUser,details.get(0).getAircraftModel(),details.get(0).getTrack(),details.get(0).getSubTrack());
        deleteCache(deleteIds);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void deleteOriginalBomInfos(LoginUser loginUser,List<Long> deleteIds) {
        BizAssertUtil.notEmpty(deleteIds, "deleteIds is empty");
        for(Long deleteId :deleteIds){
            OriginalBomV2Info info = originalBomV2InfoMapper.selectById(deleteId);
            BizAssertUtil.notNull(info, "can't find original bom info record");

            QueryWrapper<DetailOriginalV2Bom> wrapper = new QueryWrapper<>();
            wrapper.eq("aircraft_model", info.getAircraftModel());
            wrapper.eq("track", info.getTrack());
            wrapper.eq("sub_track", info.getSubTrack());
            if (originalBomV2DetailMapper.selectCount(wrapper) > 0) {
                List<Long> ids = originalBomV2DetailMapper.selectList(wrapper).stream().map(DetailOriginalV2Bom::getId).toList();
                originalBomV2DetailMapper.deleteBatchIds(ids);
                deleteCache(ids);
            }
            QueryWrapper<OriginalBomV2Info> infoWrapper = new QueryWrapper<>();
            infoWrapper.eq("aircraft_model", info.getAircraftModel());
            infoWrapper.eq("track", info.getTrack());
            infoWrapper.eq("sub_track", info.getSubTrack());
            if (originalBomV2InfoMapper.selectCount(infoWrapper) > 0) {
                List<Long> ids = originalBomV2InfoMapper.selectList(infoWrapper).stream().map(OriginalBomV2Info::getId).toList();
                originalBomV2InfoMapper.deleteBatchIds(ids);
            }
        }
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void updateOriginalBomInfo(OriginalBomV2Info originalBomV2Info) {
        BizAssertUtil.notNull(originalBomV2Info, "can't find original bom info record");
        int updateCnt = originalBomV2InfoMapper.updateById(originalBomV2Info);
        BizAssertUtil.isTrue(updateCnt == 1, "update original bom info fail");
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void updateStandardBomInfo(StandardBomV2Info standardBomV2Info) {
        BizAssertUtil.notNull(standardBomV2Info, "can't find standard bom info record");
        int updateCnt = standardBomV2InfoMapper.updateById(standardBomV2Info);
        BizAssertUtil.isTrue(updateCnt == 1, "update standard bom info fail");
    }

    private void updateStrengthBomSummary(Long strengthBomId){
        StrengthBomV2Info strengthBomV2Info = strengthBomV2InfoMapper.selectById(strengthBomId);
        List<DetailStrengthV2Bom> details = strengthBomV2DetailMapper.selectList(new QueryWrapper<DetailStrengthV2Bom>().eq("info_id", strengthBomId));
        strengthBomV2Info.setSummary(JsonUtils.toJsonString(StrengthBomV2SummaryInfo.builder()
            .count((long)details.size())
            .distinctCodeCount(details.stream().map(DetailStrengthV2Bom::getCode).distinct().count())
            .build()
        ));
        strengthBomV2InfoMapper.updateById(strengthBomV2Info);
    }

    private void updateOriginalBomSummary(LoginUser loginUser,String aircraftModel, String track, String subTrack){
        OriginalBomV2Info originalBomV2Info = bomQueryServiceV2.queryOriginalBomInfo(loginUser, aircraftModel, track, subTrack);
        Long cnt = originalBomV2DetailMapper.selectCount(new QueryWrapper<DetailOriginalV2Bom>()
            .eq("aircraft_model", originalBomV2Info.getAircraftModel())
            .eq("track", originalBomV2Info.getTrack())
            .eq("sub_track", originalBomV2Info.getSubTrack())
        );
        originalBomV2Info.setDetailCnt(cnt);
        originalBomV2InfoMapper.updateById(originalBomV2Info);
    }

    /**
     * 分批插入以便显示进度
     * */
    private <A,B> boolean insertBatch(BaseMapperPlus<A,B> baseMapperPlus, List<A> details){
        if(CollectionUtils.isEmpty(details)){
            return true;
        }
        BizEventService.updateCurrentMsg("{}/{}",String.valueOf(0), String.valueOf(details.size()));
        for (int i = 0; i < details.size(); i += 1000){
            int endIdx = Math.min(i + 1000, details.size());
            boolean b = baseMapperPlus.insertBatch(details.subList(i, endIdx));
            if(!b){
                log.info(MessageFormat.format("insert batch fail({0}-{1})",i, endIdx));
                return false;
            }
            BizEventService.updateCurrentMsg("{}/{}",String.valueOf(endIdx), String.valueOf(details.size()));
        }
        return true;
    }

    /**
     * 删除缓存
     */
    private void deleteCache(List<Long> deleteIds) {
        Set<String> redisKeys = new HashSet<>();
        for (Long id : deleteIds) {
            List<DetailStrengthV2Bom> detailStrengthV2BomList = strengthBomV2DetailMapper.selectList(new LambdaQueryWrapper<DetailStrengthV2Bom>().eq(DetailStrengthV2Bom::getOriginalDetailId, id));
            if (CollectionUtils.isNotEmpty(detailStrengthV2BomList)) {
                for (DetailStrengthV2Bom detailStrengthV2Bom : detailStrengthV2BomList) {
                    String redisKey = String.join(":",
                        RedisConstants.DETAIL_ORIGINAL_V2_BOM,
                        detailStrengthV2Bom.getAircraftModel(),
                        detailStrengthV2Bom.getTrack(),
                        detailStrengthV2Bom.getGroupType(),
                        detailStrengthV2Bom.getCode()
                    );
                    redisKeys.add(redisKey);
                }
            }
        }
        RedisUtils.deleteBySet(redisKeys);
    }
}
